﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Page.Master" CodeBehind="find.aspx.cs"
    Inherits="WebApp.find" %>

<%@ Register src="menu.ascx" tagname="menu" tagprefix="uc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="Server">
    <form id="form1" runat="server">
    <div>
        <table style="width: 100%">
            <tr>
                <td>
                    <uc1:menu ID="menu1" runat="server" />
                </td>
                <td>
                    <table style="width: 100%">
                        <tr>
                            <td colspan="2">
                                Wyszukiwarka imprez:
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 288px">
                                Wybierz kraje:<br />
                                <asp:RadioButtonList ID="countryCheckBox" runat="server" DataSourceID="LinqDataSource2"
                                    DataTextField="name" DataValueField="id">
                                </asp:RadioButtonList>
                                <asp:LinqDataSource ID="LinqDataSource2" runat="server" ContextTypeName="WebApp.LinqDataContext"
                                    Select="new (name, id)" TableName="countries">
                                </asp:LinqDataSource>
                                <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="WebApp.LinqDataContext"
                                    Select="new (name, price, start_date, end_date, country, id_country, id)" 
                                    TableName="trips" 
                                    
                                    
                                    Where="id_country == @id_country &amp;&amp; price &gt; @price &amp;&amp; price &lt; @price1 &amp;&amp; start_date &gt; @start_date &amp;&amp; end_date &lt; @end_date">
                                    <WhereParameters>
                                        <asp:ControlParameter ControlID="countryCheckBox" DefaultValue="1" Name="id_country"
                                            PropertyName="SelectedValue" Type="Int32" />
                                        <asp:ControlParameter ControlID="min_price" DefaultValue="0" Name="price" 
                                            PropertyName="Text" Type="Decimal" />
                                        <asp:ControlParameter ControlID="max_price" DefaultValue="99999999" 
                                            Name="price1" PropertyName="Text" Type="Decimal" />
                                        <asp:ControlParameter ControlID="Calendar1" Name="start_date" 
                                            PropertyName="SelectedDate" Type="DateTime" />
                                        <asp:ControlParameter ControlID="Calendar2" Name="end_date" 
                                            PropertyName="SelectedDate" Type="DateTime" />
                                    </WhereParameters>
                                </asp:LinqDataSource>
                            </td>
                            <td>
                                Wpisz przedzial cenowy
                                <br />
                                Min:&nbsp;
                                <asp:TextBox ID="min_price" runat="server"></asp:TextBox>
                                <br />
                                Maks:
                                <asp:TextBox ID="max_price" runat="server"></asp:TextBox>
                                <br />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                Data:
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 296px">
                                Rozpoczecia:
                                <asp:Calendar ID="Calendar1" runat="server" SelectedDate="2010-01-18"></asp:Calendar>
                            </td>
                            <td>
                                Zakonczenia<asp:Calendar ID="Calendar2" runat="server" 
                                    SelectedDate="2011-01-18"></asp:Calendar>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                Ilosc rekordów:
                                <asp:TextBox ID="record_number" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input id="Submit1" type="submit" value="submit" />
                            </td>
                        </tr>
                    </table>
                    <br />
                    <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
                        AutoGenerateColumns="False" DataSourceID="LinqDataSource1" 
                        OnSelectedIndexChanged="GridView1_SelectedIndexChanged" AllowPaging="True" 
                        AllowSorting="True">
                        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                        <Columns>
                            <asp:HyperLinkField DataNavigateUrlFields="id_country" 
                                DataNavigateUrlFormatString="~/country.aspx?id={0}" DataTextField="country" 
                                HeaderText="Kraj" NavigateUrl="~/country.aspx" />
                            <asp:HyperLinkField DataNavigateUrlFields="id" 
                                DataNavigateUrlFormatString="~/trip.aspx?id={0}" DataTextField="name" 
                                HeaderText="Wycieczka" NavigateUrl="~/trip.aspx" />
                            <asp:BoundField DataField="price" HeaderText="Cena" SortExpression="price" 
                                ReadOnly="True" />
                            <asp:BoundField DataField="start_date" HeaderText="Data rozpoczęcia" ReadOnly="True" 
                                SortExpression="start_date" />
                            <asp:BoundField DataField="end_date" HeaderText="Data zakończenia" ReadOnly="True" 
                                SortExpression="end_date" />
                        </Columns>
                    </asp:GridView>
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getTrips"
                        TypeName="WebApp.MyLinq"></asp:ObjectDataSource>
                    <br />
                </td>
            </tr>
        </table>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
        &nbsp;</div>
    </form>
</asp:Content>
